import Vue from 'vue'
import Router from 'vue-router'
import routes from "./router-config.js"
//注册：
Vue.use(Router)
const originalPush = Router.prototype.push 
// 全局路由守卫
Router.prototype.push =  function push(location){
    return originalPush.call(this,location).catch(err =>err)
}
    //实例化
const router =  new Router({
    mode:'history',
    routes: routes
})
router.beforeEach(async(to, from, next) => {
    console.warn(to, from, next);
    next()
})
router.afterEach(async(to, from, next) => {
    console.warn(to, from, next);
})
export default router